﻿@{
    ViewBag.Title = "Index";
}
@using Webdiyer.WebControls.Mvc
@model Webdiyer.WebControls.Mvc.PagedList< Search.Web.MySearchUnit>

<style type="text/css">
    .search-text2 {
        display: block;
        width: 528px;
        height: 26px;
        line-height: 26px;
        float: left;
        margin: 3px 5px;
        border: 1px solid gray;
        outline: none;
        font-family: 'Microsoft Yahei';
        font-size: 14px;
    }

    .search-btn2 {
        width: 102px;
        height: 32px;
        line-height: 32px;
        cursor: pointer;
        border: 0px;
        background-color: #d6000f;
        font-family: 'Microsoft Yahei';
        font-size: 16px;
        color: #f3f3f3;
    }

    .search-list-con {
        width: 640px;
        background-color: #fff;
        overflow: hidden;
        margin-top: 0px;
        padding-bottom: 15px;
        padding-top: 5px;
    }

    .search-list {
        width: 600px;
        overflow: hidden;
        margin: 15px 20px 0px 20px;
    }

        .search-list dt {
            font-family: 'Microsoft Yahei';
            font-size: 16px;
            line-height: 20px;
            margin-bottom: 7px;
            font-weight: normal;
        }

            .search-list dt a {
                color: #2981a9;
            }

                .search-list dt a em {
                    font-style: normal;
                    color: #cc0000;
                }

    #divKeyWords {
        text-align: left;
        width: 520px;
        padding-left: 4px;
    }

        #divKeyWords a {
            text-decoration: none;
        }

            #divKeyWords a:hover {
                color: red;
            }
</style>
<link href="~/lib/Autocomplete/css/ui-lightness/jquery-ui-1.8.17.custom.css" rel="stylesheet" />
@using (@Html.BeginForm(null, null, FormMethod.Get))
{
    @Html.Hidden("hidfIsOr")
    <div>@Html.TextBox("txtSearch", null, new { @class = "search-text2" })<input type="submit" value="搜索" name="btnSearch" id="btnSearch" class="search-btn2" /></div>
    <div id="divKeyWords">
        <span>热门搜索：</span>@if (ViewBag.KeyWords != null)
        {
            foreach (string v in ViewBag.KeyWords)
            {
                <a href="?txtSearch=@v">@v</a>
            }
        }
    </div>
    <div class="search-list-con">
        <dl class="search-list">
            @if (Model != null && Model.Count > 0)
            {
                foreach (var viewModel in Model)
                {
                    <dt><a href="#" target="_blank">@MvcHtmlString.Create(viewModel.Title)</a><span style="margin-left:50px;">@viewModel.Updatetime</span></dt>
                    <dd>@MvcHtmlString.Create(viewModel.Content)</dd>
                }
                @Html.Pager(Model, new PagerOptions
                {
                    // PageIndexParameterName = "Id",
                    // ShowFirstLast = false,
                    //FirstPageText = "首页",
                    //PrevPageText = "上一页",
                    //NextPageText = "下一页",
                    //LastPageText = "末页",
                    //    PageIndexBoxType = PageIndexBoxType.TextBox,
                    //  PageIndexBoxWrapperFormatString = "请输入页数{0}",
                    // GoButtonText = "转到",

                    PageIndexParameterName = "id",
                    FirstPageText = "首页",
                    PrevPageText = "上一页",
                    NextPageText = "下一页",
                    LastPageText = "末页",
                    NumericPagerItemCount = 5,
                    //ContainerTagName = "ul",
                    //  CssClass = "pagination",
                    //  CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>",
                    //  DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>",
                    // PagerItemTemplate = "<li>{0}</li>"
                })


            }

            <br />
            @*>>分页 共有 @(Model == null ? 0 : Model.TotalItemCount) 篇文章 @(Model == null ? 0 : Model.CurrentPageIndex)/@(Model == null ? 0 : Model.TotalPageCount)*@
        </dl>
    </div>
    <div>@ViewData["ShowInfo"]</div>
}
<script type="text/javascript">
    $(function () {
        $("#divKeyWords a").click(function () {
            $("#txtSearch").val($(this).html());
            $("#btnSearch").click();
        });
        getKeyWordsList("txtSearch");
        $("#isOr").click(function () {
            if ($(this).attr("checked") == "checked") {
                $("#hidfIsOr").val(true);
            }
            else {
                $("#hidfIsOr").val(false);
            }
        });
        if ($("#hidfIsOr").val() == "true") {
            $("input[type='checkbox']").prop("checked", true);
        }
    });
    //自动加载搜索列表
    function getKeyWordsList(txt) {
        if (txt == undefined || txt == "")
            return;
        $("#" + txt).autocomplete({
            source: "/LastSearch/GetKeyWordsList",
            minLength: 1
        });
    }
</script>
<script src="~/lib/Autocomplete/js/jquery-ui-1.8.17.custom.min.js"></script>
